import fetch  from 'node-fetch';

var config = {
    path: "/",
    timeout: 3000, //should be ms
    port: 443
}

// var ip :string = "20.194.29.210";
export async function TestIP(ip :string, host :string) :Promise<boolean>{
    var status :boolean= false
    try {
        let res = await fetch(`https://${ip}:${config.port}${config.path}`, {
            headers: { Host: host },
            timeout: config.timeout,
        });
        let text :String= await res.text()
        // console.log(text)
        if (text.includes('Bad Request')) {
            status = true
        }
    } catch (error) {
        // console.log(ip, error)
        status = false
    }
    return status
}
